package com.shop2cn.iapi.wxcomponent.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.wxcomponent.parameter.GetQrcodeUrlBean;
import com.shop2cn.iapi.wxcomponent.service.GetQrcodeUrlCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.Mchapp;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
/**
*查询体验二维码地址
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetQrcodeUrl{
	private static GetQrcodeUrlBean getqrcodeurlBean;
	private static GetQrcodeUrlCall getqrcodeurlCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询体验二维码地址");
	}

	@Before
	public void caseUp() {
		getqrcodeurlBean=new GetQrcodeUrlBean();
		getqrcodeurlCall=new GetQrcodeUrlCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getqrcodeurlCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetQrcodeUrl_001() {
		Logger.start(true,"查询体验二维码地址成功");
		try {
			DefGodMchWapper DefGodMchWapper=new DefGodMchWapper();
			Mchapp defmchapp = DefGodMchWapper.selectMchappByExample(null).get(0);

			getqrcodeurlBean.setMchId(defmchapp.getMchId());
			getqrcodeurlCall.setData(getqrcodeurlBean);
			getqrcodeurlCall.callService();			
			Logger.verifyEquals("200", getqrcodeurlCall.getString("code"), "验证返回");
			Logger.verifyEquals("https://api.weixin.qq.com/wxa/get_qrcode?access_token="+defmchapp.getAccessToken(), getqrcodeurlCall.getString("data"), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetQrcodeUrl_002() {
		Logger.start(true,"不输入mchid失败");
		try {
			getqrcodeurlCall.setData(getqrcodeurlBean);
			getqrcodeurlCall.callService();			
			Logger.verifyEquals("400", getqrcodeurlCall.getString("code"), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}